-- CALC_WANT_COLLECTION_BONUS
-- 计算神龙愿望我要你的收藏品奖励

return function(user)
    local ret = {};

    local bonusA = { 7321, 7322, 7323, 7324, 7325, 7326, };
    local bonusB = { 7327, 7328, 7329, 7330, 7331,
                     7332, 7333, 7335, 7336, 7337,
                     7338, 7339, 7340, 7341, 7342,
                     7343, 7344, 7345, 7346, 7347,
                     7351, 7352, };
    local bonusC = { 7353, 7354, 7355, 7356, 7357,
                     7358, 7359, 7360, 7361, 7362, }

    -- 如果获得了巨龙之力，古代龙头骨加入奖励列表
    local pet = ME.user:getActivePet();
    if true == CareerM.canLearnDragonPower(pet.classId) then
        table.insert(bonusB, 7334);
    end

    -- 如果已经拥有或可以拥有【神圣铁砧】，沃斯巴克的设计手稿加入奖励列表（7348、7349、7350）
    -- 即只学冒险系称号树最下面一条可以拿，学了不是这条线的任何其它称号就拿不到了
    local banCareer = { 202, 206, 212, 220, }
    local pet = user:getActivePet();
    local orderList = CareerM.getDepartmentList(pet);
    local canAdd = true;
    if table.indexOf(orderList, 4) ~= -1 then
        for _, careerId in pairs(banCareer) do
            if CareerM.hasJoined(careerId) then
                canAdd = false;
                break;
            end
        end
    end
    -- 如果直接可以锻造，则无需拿到设计手稿
    if FormulaM.invoke("CAN_FORGE_SPECIAL_TREASURE") then
        canAdd = false;
    end

    if canAdd then
        table.insert(bonusB, 7348);
        table.insert(bonusB, 7349);
        table.insert(bonusB, 7350);
    end

    -- 获取随机种子
    local randSeed  = DungeonM.getRandSeed("WANT_COLLECTION");
    local randSeed2 = DungeonM.getRandSeed("WANT_COLLECTION");
    local randSeed3 = DungeonM.getRandSeed("WANT_COLLECTION");

    local times = DungeonM.getDungeonMixedField("want_collection");
    if times == nil or times <= 0 then
        table.insert(ret, { 1, bonusA[randSeed % #bonusA + 1], 1});
    else
        table.insert(ret, { 1, bonusB[randSeed % #bonusB + 1], 1});
        table.removeItem(bonusB, bonusB[randSeed % #bonusB + 1]);
    end
    table.insert(ret, { 1, bonusB[randSeed2 % #bonusB + 1], 1});
    table.insert(ret, { 1, bonusC[randSeed3 % #bonusC + 1], 1});

    -- 限量級道具
    if DungeonM.getRandSeed("WANT_COLLECTION") % 1000 <= 500 then
        local bonusLimited = {};
        local limitItem = 0;

        local limitTimes1 = BuffDataM.query("dragon_collection", 1);
        local limitTimes2 = BuffDataM.query("dragon_collection", 2);
        if limitTimes1 < 10 then
            table.insert(bonusLimited, 7319);
        end
        if limitTimes2 < 10 then
            table.insert(bonusLimited, 7320);
        end

        if #bonusLimited > 0 then
            limitItem = bonusLimited[DungeonM.getRandSeed("WANT_COLLECTION") % #bonusLimited + 1];
        end

        if limitItem == 7319 then
            table.insert(ret, { 1, 7319, 1});
            BuffDataM.set("dragon_collection", 1, limitTimes1 + 5);
        end
        if limitItem == 7320 then
            table.insert(ret, { 1, 7320, 1});
            BuffDataM.set("dragon_collection", 2, limitTimes2 + 10);
        end
    end

    -- 拼图（拥有任何一张类似拼图时出现，且必定出现，每次出现1张）
    -- 拥有一种拼图就直接获得同类的WANT_COLLECTION拼图（直到都获得完）
    local puzzleId = DungeonPuzzleM.getWantCollectionPuzzle();
    if type(puzzleId) == "number" then
        table.insert(ret, {1, puzzleId, 1});
    end

    return ret;
end